package cn.edu.ujn.springboot.controller;


import cn.edu.ujn.dao.Vehicleinfo;
import cn.edu.ujn.service.IVehicleinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@CrossOrigin
public class VehicleinfoController {

    @Autowired
    private IVehicleinfoService vehicleinfoService;

    @GetMapping("/vehicleinfo")
    public List<Vehicleinfo> vehicleinfoList(Vehicleinfo queryParams){
        return vehicleinfoService.selectAll(queryParams);
    }

    @PutMapping("/vehicleinfo")
    public String vehicleinfoEdit(@RequestBody Vehicleinfo queryParam){
        return vehicleinfoService.updateByPrimaryKeySelective(queryParam) == 1 ? "success" : "fail";
    }

    @DeleteMapping("/vehicleinfo/{id}")
    public String vehicleinfoDelete(@PathVariable Integer id){
        return vehicleinfoService.deleteByPrimaryKey(id) == 1 ? "success" : "fail";
    }

    @PostMapping("/vehicleinfo")
    public String vehicleinfoAdd(@RequestBody Vehicleinfo queryParam){
        System.out.println(queryParam);
        return vehicleinfoService.insertSelective(queryParam) == 1 ? "success" : "fail";
    }

}
